<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='https://cdn.staticfile.org/react/16.4.0/umd/react.development.js'></script>
    <script src='https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js'></script>
    <!-- 生产环境中不建议使用 -->
    <script src='https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js'></script>
    <!-- PropTypes文件 -->
    <script src='https://unpkg.com/prop-types@15.6.2/prop-types.js'></script>
    <style>
        ul{
            background-color: skyblue;
            width: 80px;
            height: 150px;
            list-style: none;
            overflow: auto;
        }

        li{
            height: 30px;
            width: 80px;
        }
    </style>
</head>

<body>
    <div id='app'>
    </div>
    <script type='text/babel'>
        class Demo extends React.Component{

            state = {newArr:[],n:0}

            componentDidMount(){
                setInterval(() => {
                    this.setState({newArr:[...this.state.newArr,'新闻'+this.state.n],n:this.state.n+1})
                }, 500);
            }

            render(){
                return (
                    <ul>
                    {
                        this.state.newArr.map((item)=>{
                            return <li>{item}</li>
                        })
                    }    
                </ul>
                )
            }
        }

        ReactDOM.render(<Demo/>,document.getElementById('app'))
    </script>
</body>

</html>